package com.songcha.sakura.mvvm.novel

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
//import com.songcha.bookreader.bean._Books

//import com.songcha.sakura.ui.adapter.NovelListAdapter
import com.songcha.sakura.config.BaseConfig

import com.songcha.library_base.base.BaseFragment

import com.songcha.sakura.databinding.FragmentNovelBinding

class NovelFragment : BaseFragment() {
    companion object{
        val TAG:String= NovelFragment::class.java.simpleName
    }
    private var _binding: FragmentNovelBinding? = null

    private val binding get() = _binding!!

    //private val mList= mutableListOf<_Books.BookBean>()
    //private var mAdapter:NovelListAdapter?=null


    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {

        _binding = FragmentNovelBinding.inflate(inflater, container, false)

        initData()

        return binding.root
    }

    private fun initData(){
        val file= requireActivity().getExternalFilesDir("novel")!!
        val files=file.listFiles()
        if(files==null) return
       /* for(f in files){
            if(f.name.endsWith(".txt")){
                val book= _Books.BookBean()
                book._id=f.name
                book.path=f.absolutePath
                book.isFromSD=true
                book.title=f.name
                mList.add(book)
            }

        }

        binding.rcv.apply {
            layoutManager=LinearLayoutManager(context)
            mAdapter=NovelListAdapter(context,mList)
            adapter=mAdapter
            mAdapter!!.setOnItemClickListener{a,v,p->

            }
    }*/

    }


    override fun onDestroyView() {
        super.onDestroyView()
        _binding = null
    }
}